import request from '@/utils/request';
import { AxiosPromise } from 'axios';

/**
 * 查询账户信息列表
 * @returns {*}
 */

export const getGood = (id: number | string): AxiosPromise<GoodsDetail> => {
  return request({
    url: '/wms/product/good/' + id,
    method: 'get'
  });
};


// /goods 商品详情类型定义
export interface GoodsDetail {
  id: string;
  name: string;
  // spuCode: string;
  desc: string;
  price: string;
  oldPrice: string;
  // discount: number;
  //库存
  inventory: number;
  // salesCount: number;
  // commentCount: number;
  // collectCount: number;
  // videoScale: number;
  mainPictures: string[];
  specs: Spec[];
  sku: string;
  skus: Sku[];
  categories: Category[];
  details: Detail;
  // isPreSale: boolean;
  // isCollect?: boolean;
  // userAddresses?: any;
  similarProducts: SimilarProduct[];
  hotByDay: HotByDay[];
}
export interface Spec {
  name: string;
  values: Value[];
}
export interface Value {
  name: string;
  desc: string;
  picture?: string;
  selected?: boolean;
  disabled?: boolean;
}
export interface Sku {
  id: string;
  skuCode: string;
  price: string;
  oldPrice: string;
  inventory: number;
  specs: SkuSpec[];
}
export interface SkuSpec {
  name: string;
  valueName: string;
}
export interface SimilarProduct {
  id: string;
  name: string;
  desc: string;
  price: string;
  picture: string;
  orderNum: number;
}
export interface Category {
  id: string;
  name: string;
  layer: number;
  parent: Parent;
}
export interface Parent {
  id: string;
  name: string;
  layer: number;
  parent?: Parent;
}
export interface Detail {
  pictures: string[];
  properties: Property[];
}
export interface Property {
  name: string;
  value: string;
}
export interface HotByDay {
  id: string;
  name: string;
  desc: string;
  price: string;
  picture: string;
  orderNum: number;
}

// 单个购物车商品
export interface CartItem {
  id: string;
  skuId: string;
  name: string;
  attrsText: string;
  // specs: any[];
  picture: string;
  price: string;
  oldPrice: string;
  nowOriginalPrice: string;
  selected: boolean;
  stock: number;
  quantity: number;
  isEffective: boolean;
  // discount?: any;
  isCollect: boolean;
  postFee: number;
}
// 购物车列表
export type CartList = CartItem[];
